package com.yyh1;

public class ITworker {
    // 私有属性（统一英文命名）
    private String name;
    private int age = 15; // 默认值15
    private final String technicalDirection; // 只读属性
    private int workYears;
    private String company;
    private String position;

    public ITworker(String name, int age,String technicalDirection, int workYears) {
        this.name = name;
        setAge(age);
        this.technicalDirection = technicalDirection;
        this.workYears = workYears;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }
    //判断年龄
    public void setAge(int age) {
        if (age < 15){
            System.out.println("警告：年龄必须≥15岁，已自动设置为15岁");
        }else {
            this.age = age;
        }
    }

    public String getTechnicalDirection() {
        return technicalDirection;
    }

    public int getWorkYears() {
        return workYears;
    }

    public void setWorkYears(int workYears) {
        this.workYears = workYears;
    }

    // 工作方法（通过参数接收数据）
    public String work(String company, String position) {
        this.company = company;
        this.position = position;
        return "姓名："+name+"\n"
                +"年龄："+age+"\n"
                +"技术方向："+technicalDirection+"\n"
                +"工作年限："+workYears+"\n"
                +"目前就职于："+company+"\n"
                +"职务："+position;
    }
}
